package View;

import Model.IUpdatable;
import Presenter.PlayerInfoPresenter;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * @author Ikenna
 *
 */
/**
 * @author Ikenna
 *
 */
/**
 * @author Ikenna
 *
 */
public class PlayerInfoView extends JPanel implements IUpdatable {
	/**
	 * 
	 */
	private final PlayerInfoPresenter presenter  = new PlayerInfoPresenter();

	/**
	 * 
	 */
	private final JLabel nameField;
	
	/**
	 * 
	 */
	private final JLabel creditsField;
	
	/**
	 * 
	 */
	private final JLabel pilotLevelField;
	
	/**
	 * 
	 */
	private final JLabel fighterLevelField;
	
	/**
	 * 
	 */
	private final JLabel traderLevelField;
	
	/**
	 * 
	 */
	private final JLabel engineerLevelField;
	
	/**
	 * 
	 */
	private final JLabel shipField;
	
	/**
	 * 
	 */
	//private final JLabel      cc;
	
	/**
	 * 
	 */
	private final JLabel currentFuelField;
	/**
     * 
     */
    private final JLabel planetField;

	/**
	 * Constrcutor
	 */
	public PlayerInfoView(){
		setLayout(new GridLayout(12, 2));
		
	 nameField = new JLabel(presenter.getPlayerName());
	 creditsField = new JLabel("" + presenter.getPlayerCredits());
	 pilotLevelField = new JLabel("" + presenter.getPlayerPilotLevel());
	 fighterLevelField = new JLabel("" + presenter.getPlayerFighterLevel());
	 traderLevelField = new JLabel("" + presenter.getPlayerTraderLevel());
	 engineerLevelField = new JLabel("" + presenter.getPlayerEngineerLevel());
	 shipField = new JLabel(presenter.getPlayerShipName());
	 currentFuelField = new JLabel(presenter.getCurrentFuel());
	 planetField = new JLabel("" + presenter.getCurrentPlanet().getName());
	
	 final JPanel equipment = new JPanel();
	 equipment.setLayout(new GridLayout(1, 3));
		add(new JLabel("Name:\t"));
		add(nameField);
		add(new JLabel("Ship:\t"));
		add(shipField);
		add(new JLabel("Current Planet\t"));
		add(planetField);
		add(new JLabel("Current Fuel\t"));
		add(currentFuelField);
		add(new JLabel("Credits:\t"));
		add(creditsField);
		add(new JLabel("Pilot Level:\t"));
		add(pilotLevelField);
		add(new JLabel("Fighter Level:\t"));
		add(fighterLevelField);
		add(new JLabel("Trader Level:\t"));
		add(traderLevelField);
		add(new JLabel("Engineer Level:\t"));
		add(engineerLevelField);
		add(equipment);	
	}

	public void update(){
		nameField.setText(presenter.getPlayerName());
		creditsField.setText("" + presenter.getPlayerCredits());
		pilotLevelField.setText("" + presenter.getPlayerPilotLevel());
		fighterLevelField.setText("" + presenter.getPlayerFighterLevel());
		traderLevelField.setText("" + presenter.getPlayerTraderLevel());
		engineerLevelField.setText("" + presenter.getPlayerEngineerLevel());
		shipField.setText(presenter.getPlayerShipName());
		planetField.setText("" + presenter.getCurrentPlanet().getName());
		currentFuelField.setText(presenter.getCurrentFuel());
	}
}
